package com.scx.controller.voucher;

import com.scx.entity.Voucher;
import com.scx.result.Result;
import com.scx.service.IVoucherService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/voucher")
@Api("优惠券管理接口")
@Slf4j
public class VoucherController {

    @Resource
    private IVoucherService voucherService;

    @PostMapping("/seckill")
    @ApiOperation("新增优惠券")
    public Result addSeckillVoucher(@RequestBody Voucher voucher) {
        log.info("新增优惠券:{}",voucher);
        voucherService.addSeckillVoucher(voucher);
        return Result.success(voucher.getId());
    }

    @GetMapping("/list")
    @ApiOperation("查询店铺的优惠券列表")
    public Result queryVoucherOfShop() {
        log.info("查询店铺的优惠券列表");
       return voucherService.queryVoucher();
    }
}
